<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    // 非空字符为true，空为false
    console.log( Boolean(true) )
    console.log( Boolean("true") )
    console.log( Boolean("false") )
    console.log( Boolean("hello") )
    console.log( Boolean(" ") )
    console.log( Boolean("") )

    // 非0为true，0为false
    console.log( Boolean(0) )
    console.log( Boolean(1) )
    console.log( Boolean(4) )
    console.log( Boolean(-4) )
    console.log( Boolean(-4.1724728) )

    

    // 对象数组函数都是true
    console.log( Boolean({}) )
    console.log( Boolean({name:false}) )
    console.log( Boolean([]) )
    console.log( Boolean([false]) )
    console.log( Boolean(function(){}) )

    // undefined,null,NaN都是false
    console.log( Boolean(undefined) )
    console.log( Boolean(null) )
    console.log( Boolean(NaN) )


    // 逻辑短路

    // 或的逻辑短路：
        // 一个true真，一个false值，取true值
        // 都是true值，取第一个true值
        // 都是false值，取最后一个false值

    // 作业：且的逻辑短路规则

    // console.log(true || false)

    // console.log(1 || 0)

    // console.log("hello" || undefined)

    // console.log(NaN || {});

    // console.log("" || 365);

    // console.log(1 || 2);

    // console.log(2 || 1);

    // console.log(0 || NaN);

    // console.log(NaN || 0);


    // 自己练习

    // console.log(Boolean(""));
    // console.log(Boolean(" "));
    // console.log(Boolean("hello"));
    // console.log(Boolean("124")); 

    // console.log(Boolean([]));
    // console.log(Boolean(function(){}));
    // console.log(Boolean([1253]));
    // console.log(Boolean({}));
    // console.log(Boolean({name:false}));


    // console.log(Boolean(undefined));
    // console.log(Boolean(null));
    // console.log(Boolean(NaN));




</script>
</html>